SystemVerilog Constraints

您所在的位置:网站首页 verilog constrain SystemVerilog Constraints

SystemVerilog Constraints

2023-10-15 13:17| 来源: 网络整理| 查看: 265

What are direct tests ?

Verification engineers will first create something known as a verification plan that details every feature of the design required to be tested in RTL simulations and how each test will create independent scenarios that target a particular feature.

For example, if there's a peripheral that needs its registers to be configured such that it starts an AXI bus transaction, then we would have different tests to configure those registers differently and achieve a good coverage.

These are direct tests where each test does a particular task to accomplish something.

What are randomized tests ?

Complex designs have a lot of scenarios and many corner cases that are better verified by randomized tests and take much less effort and time. Taking the same example from above, a test will configure the peripheral registers with random values every time the test is run with a different seed thereby achieving different scenarios for every run. This will ensure that we hit corner cases and uncover any hidden bugs.

Constraints

SystemVerilog allows users to specify constraints in a compact, declarative way which are then processed by an internal solver to generate random values that satisfy all conditions. Basically constraints are nothing more than a way to let us define what legal values should be assigned to the random variables. A normal variable is declared to be random by the keyword rand.

class Pkt; rand bit [7:0] addr; rand bit [7:0] data; constraint addr_limit { addr

The example above declares a class called Pkt with a constraint on its address field. Note that both its properties are prefixed with the rand keyword which tells the solver that these variables should be randomized when asked to. The constraint is called addr_limit and specifies that the solver can allot any random value for the address that is below or equal to 8'h8. Since the 8-bit variable addr is of type bit, it can have any value from 0 to 255, but with the constraint valid values will be limited to 11.

As you can see, this powerful feature will allow us to create variables that are constrained within ranges that are valid for the design and will have a much better verification impact. In the next few sessions, we'll see how to effectively use different constructs within SystemVerilog that allow us to describe constraints in a better way.

SystemVerilog Constraint ExamplesSystemVerilog RandomizationSystemVerilog rand VariablesSystemVerilog Constraint BlocksSystemVerilog Implication ConstraintSystemVerilog Constraint 'inside'SystemVerilog Static ConstraintsSystemVerilog foreach ConstraintSystemVerilog Inline ConstraintsSystemVerilog Soft ConstraintsSystemVerilog Disable ConstraintsSystemVerilog pre_randomize & post_randomizeSystemVerilog Disable RandomizationSystemVerilog randcaseSystemVerilog Array RandomizationBus Protocol ConstraintsMemory Partitioning Example


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3